package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.mapper.entity.Student;
import com.example.demo.mapper.entity.StudentCertification;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface CertificationManageMapper extends BaseMapper<StudentCertification> {

    @Select("SELECT * FROM student_certification")
    List<StudentCertification> getCertificationList();

    @Select("SELECT * FROM student_certification WHERE student_number = #{studentNumber}")
    StudentCertification getByNumber(String studentNumber);

    @Update("UPDATE `student_certification` SET state = #{state} WHERE student_number = #{studnetNumber}")
    void approveByNumber(StudentCertification curStudent);

    @Update("UPDATE `student` SET state = 2 WHERE id = #{id}")
    int updateStudentState(int id);


    @Select("SELECT id FROM student WHERE number=#{number}")
    int getIdByNumber(String number);
    @Select("SELECT name FROM student WHERE id=#{id}")
    String getStudentName(int id);
}
